package de.koller.million.card.engine.player;

import de.koller.million.card.CNode;
import de.koller.million.card.frame.player.PlayerFrame;
import de.koller.million.card.frame.util.NewsModel;
import de.koller.oceanFramework.util.MIn;
import de.koller.oceanFramework.util.MOut;

public class Player extends CNode {
	
	public final int id;
	public PlayerFrame view = null;
	public final NewsModel news = new NewsModel( 50 );
	public final NewsModel lootNews = new NewsModel( 20 );
	
	public final Equipt equipt = new Equipt( this );
	public final PlayerStats stats = new PlayerStats( this );
	
	public Player( int id ) {
		this.id = id;
	}

	@Override
	protected void init() {
		super.init();
		croot.engine.playerContainer.players.add( this );
		
		//news.publish( new TextNewsEntry( croot.getTime(), "Spieler geladen." ) );
	}

	public void save( MOut o ) {

	}
	
	public void load( MIn i ) {

	}
	
	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
		
//		Item loot = croot.engine.itemManager.createItem( this );
//		
//		boolean b = false;
//		Item old = null;
//		if( equipt.isBetter( loot ) ) {
//			old = equipt.equip( loot );
//			b = true;
//			
//			if( old != null )
//				news.publish( new TextNewsEntry( croot.getTime(), old.toPrintString() + " -> " + loot.toPrintString() ) );
//			else
//				news.publish( new TextNewsEntry( croot.getTime(), "[leer] -> " + loot.toPrintString() ) );
//		}
//	
//		lootNews.publish( new TextNewsEntry( croot.getTime(), "bekam " + loot.toPrintString() + (b?"(angezogen)":"") ) );
//	
//		progress.checkProgress();
	}

	@Override
	protected void release() {
		super.release();
		croot.engine.playerContainer.players.remove( this );
	}

	@Override
	public String toString() {
		return "Spieler " + id;
	}

}
